# -*- coding: utf-8 -*-
"""
Created on Tue Sep 20 13:42:34 2022

@author: obiri
"""

import mpctools as mpc
import casadi
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import time
import sys

font = {'family' : 'monospace', 'weight' : 'bold', 'size'   : 18}
mpl.rc('font', **font)  # pass in the font dict as kwargs
mpl.rcParams['axes.linewidth'] = 3.0
 

Delta = 60 # Time step
Nsim = 50
tplot = np.arange(Nsim+1)*Delta 

#NOMINAL 
# estimate_nominal = np.load('estimate_nominal.npy' )

#3CASES
estimate_case1 = np.load('x_hat_C1.npy' )
estimate_case2 = np.load('x_hat_C2.npy' )
estimate_case3 = np.load('x_hat_C3.npy' )
actual_trajectories = np.load('x_actual_C3.npy' )



#####################-----------all states on same plot---3 CASES-----------###########################
fig_1, axs = plt.subplots(4, 4)
axs[0, 0].plot(tplot[:-1], actual_trajectories[:,0], 'r',linewidth=3)
axs[0, 0].plot(tplot[:-1], estimate_case1[:,0], '-.b', linewidth=3)
axs[0, 0].plot(tplot[:-1], estimate_case2[:,0], ':k', linewidth=3)
axs[0, 0].plot(tplot[:-1], estimate_case3[:,0], '--g', linewidth=3)
axs[0, 0].set_ylabel('Xv$_1$(cell/L)',  weight='bold', family='monospace', size=13)
axs[0, 0].set_xlim([0, 2000])


axs[0, 1].plot(tplot[:-1],actual_trajectories[:,1], 'r', linewidth=3)
axs[0, 1].plot(tplot[:-1], estimate_case1[:,1],  '-.b' , linewidth=3)
axs[0, 1].plot(tplot[:-1], estimate_case2[:,1], ':k', linewidth=3)
axs[0, 1].plot(tplot[:-1], estimate_case3[:,1], '--g', linewidth=3)
axs[0, 1].set_ylabel('Xt$_1$(cell/L)', weight='bold', family='monospace', size=13)
axs[0, 1].set_xlim([0, 2000])

axs[1, 0].plot(tplot[:-1], actual_trajectories[:,2], 'r' , linewidth=3)
axs[1, 0].plot(tplot[:-1], estimate_case1[:,2],  '-.b', linewidth=3)
axs[1, 0].plot(tplot[:-1], estimate_case2[:,2], ':k', linewidth=3)
axs[1, 0].plot(tplot[:-1], estimate_case3[:,2], '--g', linewidth=3)
axs[1, 0].set_ylabel('GLC$_1$(mM)',  weight='bold', family='monospace', size=13)
axs[1, 0].set_xlim([0, 2000])

axs[1, 1].plot(tplot[:-1], actual_trajectories[:,3], 'r', linewidth=3)
axs[1, 1].plot(tplot[:-1], estimate_case1[:,3],  '-.b', linewidth=3)
axs[1, 1].plot(tplot[:-1], estimate_case2[:,3], ':k', linewidth=3)
axs[1, 1].plot(tplot[:-1], estimate_case3[:,3], '--g', linewidth=3)
axs[1, 1].set_ylabel('GLN$_1$(mM)',  weight='bold', family='monospace', size=13)
axs[1, 1].set_xlim([0, 2000])

axs[2, 0].plot(tplot[:-1], actual_trajectories[:,4], 'r', linewidth=3)
axs[2, 0].plot(tplot[:-1], estimate_case1[:,4],  '-.b', linewidth=3)
axs[2, 0].plot(tplot[:-1], estimate_case2[:,4], ':k', linewidth=3)
axs[2, 0].plot(tplot[:-1], estimate_case3[:,4], '--g', linewidth=3)
axs[2, 0].set_ylabel('LAC$_1$(mM)',  weight='bold', family='monospace', size=13)
axs[2, 0].set_xlim([0, 2000])

axs[2, 1].plot(tplot[:-1], actual_trajectories[:,5], 'r', linewidth=3)
axs[2, 1].plot(tplot[:-1], estimate_case1[:,5],  '-.b', linewidth=3)
axs[2, 1].plot(tplot[:-1], estimate_case2[:,5], ':k', linewidth=3)
axs[2, 1].plot(tplot[:-1], estimate_case3[:,5], '--g', linewidth=3)
axs[2, 1].set_ylabel('AMM$_1$(mM)',  weight='bold', family='monospace', size=13)
axs[2, 1].set_xlim([0, 2000])

axs[3, 0].plot(tplot[:-1], actual_trajectories[:,6], 'r', linewidth=3)
axs[3, 0].plot(tplot[:-1], estimate_case1[:,6],  '-.b', linewidth=3)
axs[3, 0].plot(tplot[:-1], estimate_case2[:,6], ':k', linewidth=3)
axs[3, 0].plot(tplot[:-1], estimate_case3[:,6], '--g', linewidth=3)
axs[3, 0].set_ylabel('mAb$_1$(mg/L)',  weight='bold', family='monospace', size=13)
axs[3, 0].set_xlim([0, 2000])
axs[3, 0].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)

axs[3, 1].plot(tplot[:-1], actual_trajectories[:,7], 'r', linewidth=3)
axs[3, 1].plot(tplot[:-1], estimate_case1[:,7], '-.b', linewidth=3)
axs[3, 1].plot(tplot[:-1], estimate_case2[:,7], ':k', linewidth=3)
axs[3, 1].plot(tplot[:-1], estimate_case3[:,7], '--g', linewidth=3)
axs[3, 1].set_ylabel('Xv$_2$(cell/L)',  weight='bold', family='monospace', size=13)
axs[3, 1].set_xlim([0, 2000])
axs[3, 1].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)


axs[0, 2].plot(tplot[:-1], actual_trajectories[:,8], 'r', linewidth=3)
axs[0, 2].plot(tplot[:-1], estimate_case1[:,8], '-.b', linewidth=3)
axs[0, 2].plot(tplot[:-1], estimate_case2[:,8], ':k', linewidth=3)
axs[0, 2].plot(tplot[:-1], estimate_case3[:,8], '--g', linewidth=3)
axs[0, 2].set_ylabel('Xt$_2$(cell/L)',  weight='bold', family='monospace', size=13)
axs[0, 2].set_xlim([0, 2000])

axs[0, 3].plot(tplot[:-1], actual_trajectories[:,9], 'r', linewidth=3)
axs[0, 3].plot(tplot[:-1], estimate_case1[:,9], '-.b', linewidth=3)
axs[0, 3].plot(tplot[:-1], estimate_case2[:,9], ':k', linewidth=3)
axs[0, 3].plot(tplot[:-1], estimate_case3[:,9], '--g', linewidth=3)
axs[0, 3].set_ylabel('GLC$_2$(mM)',  weight='bold', family='monospace', size=13)
axs[0, 3].set_xlim([0, 2000])

axs[1, 2].plot(tplot[:-1], actual_trajectories[:,10], 'r', linewidth=3)
axs[1, 2].plot(tplot[:-1], estimate_case1[:,10], '-.b', linewidth=3)
axs[1, 2].plot(tplot[:-1], estimate_case2[:,10], ':k', linewidth=3)
axs[1, 2].plot(tplot[:-1], estimate_case3[:,10], '--g', linewidth=3)
axs[1, 2].set_ylabel('GLN$_2$(mM)',  weight='bold', family='monospace', size=13)
axs[1, 2].set_xlim([0, 2000])

axs[1, 3].plot(tplot[:-1], actual_trajectories[:,11], 'r',linewidth=3)
axs[1, 3].plot(tplot[:-1], estimate_case1[:,11], '-.b', linewidth=3)
axs[1, 3].plot(tplot[:-1], estimate_case2[:,11], ':k', linewidth=3)
axs[1, 3].plot(tplot[:-1], estimate_case3[:,11], '--g', linewidth=3)
axs[1, 3].set_ylabel('LAC$_2$(mM)',  weight='bold', family='monospace', size=13)
axs[1, 3].set_xlim([0, 2000])

axs[2, 2].plot(tplot[:-1], actual_trajectories[:,12], 'r', linewidth=3)
axs[2, 2].plot(tplot[:-1], estimate_case1[:,12], '-.b', linewidth=3)
axs[2, 2].plot(tplot[:-1], estimate_case2[:,12], ':k', linewidth=3)
axs[2, 2].plot(tplot[:-1], estimate_case3[:,12], '--g', linewidth=3)
axs[2, 2].set_ylabel('AMM$_2$(mM)',  weight='bold', family='monospace', size=13)
axs[2, 2].set_xlim([0, 2000])

axs[2, 3].plot(tplot[:-1], actual_trajectories[:,13], 'r', linewidth=3)
axs[2, 3].plot(tplot[:-1], estimate_case1[:,13], '-.b', linewidth=3)
axs[2, 3].plot(tplot[:-1], estimate_case2[:,13], ':k', linewidth=3)
axs[2, 3].plot(tplot[:-1], estimate_case3[:,13], '--g', linewidth=3)
axs[2, 3].set_ylabel('mAb$_2$(mg/L)',  weight='bold', family='monospace', size=13)
axs[2, 3].set_xlim([0, 2000])

axs[3, 2].plot(tplot[:-1], actual_trajectories[:,14], 'r', linewidth=3)
axs[3, 2].plot(tplot[:-1], estimate_case1[:,14], '-.b', linewidth=3)
axs[3, 2].plot(tplot[:-1], estimate_case2[:,14], ':k', linewidth=3)
axs[3, 2].plot(tplot[:-1], estimate_case3[:,14], '--g', linewidth=3)
axs[3, 2].set_ylabel('T($\degree$C)',  weight='bold', family='monospace', size=13)
axs[3, 2].set_xlim([0, 2000])
axs[3, 2].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)

axs[3, 3].plot(tplot[:-1], actual_trajectories[:,15], 'r', linewidth=3)
axs[3, 3].plot(tplot[:-1], estimate_case1[:,15], '-.b', linewidth=3)
axs[3, 3].plot(tplot[:-1], estimate_case2[:,15], ':k', linewidth=3)
axs[3, 3].plot(tplot[:-1], estimate_case3[:,15], '--g', linewidth=3)
axs[3, 3].set_ylabel('c$_{buffer}$(mg/L)',  weight='bold', family='monospace', size=13)
axs[3, 3].set_xlim([0, 2000])


fig_1.legend(['Actual', 'Case1', 'Case2', 'Case3'], ncol=4, loc='upper center',frameon=False)
plt.rcParams["figure.figsize"] =  [8.00, 7.00]
plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
fig_1.tight_layout()
plt.show()





# #####################-----------all states on same plot---NOMINAL----------###########################
# fig_0, axs = plt.subplots(4, 4)
# axs[0, 0].plot(tplot[:-1], actual_trajectories[:,0], 'r',linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_nominal[:,0], '-.b', linewidth=3)
# axs[0, 0].set_ylabel('Xv$_1$(cell/L)',  weight='bold', family='monospace', size=13)
# axs[0, 0].set_xlim([0, 900])


# axs[0, 1].plot(tplot[:-1],actual_trajectories[:,1], 'r', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_nominal[:,1],  '-.b' , linewidth=3)
# axs[0, 1].set_ylabel('Xt$_1$(cell/L)', weight='bold', family='monospace', size=13)
# axs[0, 1].set_xlim([0, 900])

# axs[1, 0].plot(tplot[:-1], actual_trajectories[:,2], 'r' , linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_nominal[:,2],  '-.b', linewidth=3)
# axs[1, 0].set_ylabel('GLC$_1$(mM)',  weight='bold', family='monospace', size=13)
# axs[1, 0].set_xlim([0, 900])

# axs[1, 1].plot(tplot[:-1], actual_trajectories[:,3], 'r', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_nominal[:,3],  '-.b', linewidth=3)
# axs[1, 1].set_ylabel('GLN$_1$(mM)',  weight='bold', family='monospace', size=13)
# axs[1, 1].set_xlim([0, 900])

# axs[2, 0].plot(tplot[:-1], actual_trajectories[:,4], 'r', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_nominal[:,4],  '-.b', linewidth=3)
# axs[2, 0].set_ylabel('LAC$_1$(mM)',  weight='bold', family='monospace', size=13)
# axs[2, 0].set_xlim([0, 900])

# axs[2, 1].plot(tplot[:-1], actual_trajectories[:,5], 'r', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_nominal[:,5],  '-.b', linewidth=3)
# axs[2, 1].set_ylabel('AMM$_1$(mM)',  weight='bold', family='monospace', size=13)
# axs[2, 1].set_xlim([0, 900])

# axs[3, 0].plot(tplot[:-1], actual_trajectories[:,6], 'r', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_nominal[:,6],  '-.b', linewidth=3)
# axs[3, 0].set_ylabel('mAb$_1$(mg/L)',  weight='bold', family='monospace', size=13)
# axs[3, 0].set_xlim([0, 900])
# axs[3, 0].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)

# axs[3, 1].plot(tplot[:-1], actual_trajectories[:,7], 'r', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_nominal[:,7], '-.b', linewidth=3)
# axs[3, 1].set_ylabel('Xv$_2$(cell/L)',  weight='bold', family='monospace', size=13)
# axs[3, 1].set_xlim([0, 900])
# axs[3, 1].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)


# axs[0, 2].plot(tplot[:-1], actual_trajectories[:,8], 'r', linewidth=3)
# axs[0, 2].plot(tplot[:-1], estimate_nominal[:,8], '-.b', linewidth=3)
# axs[0, 2].set_ylabel('Xt$_2$(cell/L)',  weight='bold', family='monospace', size=13)
# axs[0, 2].set_xlim([0, 900])

# axs[0, 3].plot(tplot[:-1], actual_trajectories[:,9], 'r', linewidth=3)
# axs[0, 3].plot(tplot[:-1], estimate_nominal[:,9], '-.b', linewidth=3)
# axs[0, 3].set_ylabel('GLC$_2$(mM)',  weight='bold', family='monospace', size=13)
# axs[0, 3].set_xlim([0, 900])

# axs[1, 2].plot(tplot[:-1], actual_trajectories[:,10], 'r', linewidth=3)
# axs[1, 2].plot(tplot[:-1], estimate_nominal[:,10], '-.b', linewidth=3)
# axs[1, 2].set_ylabel('GLN$_2$(mM)',  weight='bold', family='monospace', size=13)
# axs[1, 2].set_xlim([0, 900])

# axs[1, 3].plot(tplot[:-1], actual_trajectories[:,11], 'r',linewidth=3)
# axs[1, 3].plot(tplot[:-1], estimate_nominal[:,11], '-.b', linewidth=3)
# axs[1, 3].set_ylabel('LAC$_2$(mM)',  weight='bold', family='monospace', size=13)
# axs[1, 3].set_xlim([0, 900])

# axs[2, 2].plot(tplot[:-1], actual_trajectories[:,12], 'r', linewidth=3)
# axs[2, 2].plot(tplot[:-1], estimate_nominal[:,12], '-.b', linewidth=3)
# axs[2, 2].set_ylabel('AMM$_2$(mM)',  weight='bold', family='monospace', size=13)
# axs[2, 2].set_xlim([0, 900])

# axs[2, 3].plot(tplot[:-1], actual_trajectories[:,13], 'r', linewidth=3)
# axs[2, 3].plot(tplot[:-1], estimate_nominal[:,13], '-.b', linewidth=3)
# axs[2, 3].set_ylabel('mAb$_2$(mg/L)',  weight='bold', family='monospace', size=13)
# axs[2, 3].set_xlim([0, 900])

# axs[3, 2].plot(tplot[:-1], actual_trajectories[:,14], 'r', linewidth=3)
# axs[3, 2].plot(tplot[:-1], estimate_nominal[:,14], '-.b', linewidth=3)
# axs[3, 2].set_ylabel('T($\degree$C)',  weight='bold', family='monospace', size=13)
# axs[3, 2].set_xlim([0, 900])
# axs[3, 2].set_xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)

# axs[3, 3].plot(tplot[:-1], actual_trajectories[:,15], 'r', linewidth=3)
# axs[3, 3].plot(tplot[:-1], estimate_nominal[:,15], '-.b', linewidth=3)
# axs[3, 3].set_ylabel('c$_{buffer}$(mg/L)',  weight='bold', family='monospace', size=13)
# axs[3, 3].set_xlim([0, 900])



# fig_0.legend(['Actual', 'estimate'], ncol=2, loc='upper center',frameon=False)
# plt.rcParams["figure.figsize"] =  [16.00, 7.00]
# # plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
# plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
# fig_0.tight_layout()
# plt.show()



# fig_1.legend(['Actual', 'Case1', 'Case2', 'Case3'], ncol=4, loc='upper center',frameon=False)
# plt.rcParams["figure.figsize"] =  [8.00, 7.00]
# plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
# fig_1.tight_layout()
# plt.show()







# #####################-----------2 subplots-states-----------###########################
# fig_1, axs = plt.subplots(4, 2)
# axs[0, 0].plot(tplot[:-1], actual_trajectories[:,0], 'r',linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case1[:,0], '-.b', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case2[:,0], ':k', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case3[:,0], '--g', linewidth=3)
# axs[0, 0].set_ylabel('Xv$_1$ (cell/L)')
# axs[0, 0].grid(linewidth=0.5, linestyle='-.')
# axs[0, 0].set_xlim([0, 900])


# axs[0, 1].plot(tplot[:-1],actual_trajectories[:,1], 'r', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case1[:,1],  '-.b' , linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case2[:,1], ':k', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case3[:,1], '--g', linewidth=3)
# axs[0, 1].set_ylabel('Xt$_1$ (cell/L)')
# axs[0, 1].grid(linewidth=0.5, linestyle='-.')
# axs[0, 1].set_xlim([0, 900])

# axs[1, 0].plot(tplot[:-1], actual_trajectories[:,2], 'r' , linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case1[:,2],  '-.b', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case2[:,2], ':k', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case3[:,2], '--g', linewidth=3)
# axs[1, 0].set_ylabel('GLC$_1$ (mM)')
# axs[1, 0].grid(linewidth=0.5, linestyle='-.')
# axs[1, 0].set_xlim([0, 900])

# axs[1, 1].plot(tplot[:-1], actual_trajectories[:,3], 'r', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case1[:,3],  '-.b', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case2[:,3], ':k', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case3[:,3], '--g', linewidth=3)
# axs[1, 1].set_ylabel('GLN$_1$ (mM)')
# axs[1, 1].grid(linewidth=0.5, linestyle='-.')
# axs[1, 1].set_xlim([0, 900])

# axs[2, 0].plot(tplot[:-1], actual_trajectories[:,4], 'r', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case1[:,4],  '-.b', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case2[:,4], ':k', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case3[:,4], '--g', linewidth=3)
# axs[2, 0].set_ylabel('LAC$_1$ (mM)')
# axs[2, 0].grid(linewidth=0.5, linestyle='-.')
# axs[2, 0].set_xlim([0, 900])

# axs[2, 1].plot(tplot[:-1], actual_trajectories[:,5], 'r', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case1[:,5],  '-.b', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case2[:,5], ':k', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case3[:,5], '--g', linewidth=3)
# axs[2, 1].set_ylabel('AMM$_1$ (mM)')
# axs[2, 1].grid(linewidth=0.5, linestyle='-.')
# axs[2, 1].set_xlim([0, 900])

# axs[3, 0].plot(tplot[:-1], actual_trajectories[:,6], 'r', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case1[:,6],  '-.b', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case2[:,6], ':k', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case3[:,6], '--g', linewidth=3)
# axs[3, 0].set_ylabel('mAb$_1$ (mg/L)')
# axs[3, 0].grid(linewidth=0.5, linestyle='-.')
# axs[3, 0].set_xlim([0, 900])

# axs[3, 1].plot(tplot[:-1], actual_trajectories[:,7], 'r', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case1[:,7], '-.b', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case2[:,7], ':k', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case3[:,7], '--g', linewidth=3)
# axs[3, 1].set_ylabel('Xv$_2$ (cell/L)')
# axs[3, 1].grid(linewidth=0.5, linestyle='-.')
# axs[3, 1].set_xlim([0, 900])

# # # fig_1.tight_layout()
# # plt.legend(['Actual', 'Case1', 'Case2', 'Case3'], ncol=3)
# # # fig_1.legend(['Actual', 'Case1', 'Case2', 'Case3'])
# # plt.rcParams["figure.figsize"] =  [8.00, 7.00]
# # plt.setp(axs[-1, :], xlabel='Time(min)')

# plt.legend(['Actual', 'Case2', 'Case3'], ncol=3)
# plt.rcParams["figure.figsize"] =  [8.00, 7.00]
# plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
# plt.show()


# fig_2, axs = plt.subplots(4, 2)
# axs[0, 0].plot(tplot[:-1], actual_trajectories[:,8], 'r', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case1[:,8], '-.b', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case2[:,8], ':k', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case3[:,8], '--g', linewidth=3)
# axs[0, 0].set_ylabel('Xt$_2$ (cell/L)')
# axs[0, 0].grid(linewidth=0.5, linestyle='-.')
# axs[0, 0].set_xlim([0, 900])

# axs[0, 1].plot(tplot[:-1], actual_trajectories[:,9], 'r', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case1[:,9], '-.b', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case2[:,9], ':k', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case3[:,9], '--g', linewidth=3)
# axs[0, 1].set_ylabel('GLC$_2$ (mM)')
# axs[0, 1].grid(linewidth=0.5, linestyle='-.')
# axs[0, 1].set_xlim([0, 900])

# axs[1, 0].plot(tplot[:-1], actual_trajectories[:,10], 'r', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case1[:,10], '-.b', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case2[:,10], ':k', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case3[:,10], '--g', linewidth=3)
# axs[1, 0].set_ylabel('GLN$_2$ (mM)')
# axs[1, 0].grid(linewidth=0.5, linestyle='-.')
# axs[1, 0].set_xlim([0, 900])

# axs[1, 1].plot(tplot[:-1], actual_trajectories[:,11], 'r',linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case1[:,11], '-.b', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case2[:,11], ':k', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case3[:,11], '--g', linewidth=3)
# axs[1, 1].set_ylabel('LAC$_2$ (mM)')
# axs[1, 1].grid(linewidth=0.5, linestyle='-.')
# axs[1, 1].set_xlim([0, 900])

# axs[2, 0].plot(tplot[:-1], actual_trajectories[:,12], 'r', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case1[:,12], '-.b', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case2[:,12], ':k', linewidth=3)
# axs[2, 0].plot(tplot[:-1], estimate_case3[:,12], '--g', linewidth=3)
# axs[2, 0].set_ylabel('AMM$_2$ (mM)')
# axs[2, 0].grid(linewidth=0.5, linestyle='-.')
# axs[2, 0].set_xlim([0, 900])

# axs[2, 1].plot(tplot[:-1], actual_trajectories[:,13], 'r', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case1[:,13], '-.b', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case2[:,13], ':k', linewidth=3)
# axs[2, 1].plot(tplot[:-1], estimate_case3[:,13], '--g', linewidth=3)
# axs[2, 1].set_ylabel('mAb$_2$ (mg/L)')
# axs[2, 1].grid(linewidth=0.5, linestyle='-.')
# axs[2, 1].set_xlim([0, 900])

# axs[3, 0].plot(tplot[:-1], actual_trajectories[:,14], 'r', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case1[:,14], '-.b', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case2[:,14], ':k', linewidth=3)
# axs[3, 0].plot(tplot[:-1], estimate_case3[:,14], '--g', linewidth=3)
# axs[3, 0].set_ylabel('T ($\degree$C)')
# axs[3, 0].grid(linewidth=0.5, linestyle='-.')
# axs[3, 0].set_xlim([0, 900])

# axs[3, 1].plot(tplot[:-1], actual_trajectories[:,15], 'r', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case1[:,15], '-.b', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case2[:,15], ':k', linewidth=3)
# axs[3, 1].plot(tplot[:-1], estimate_case3[:,15], '--g', linewidth=3)
# axs[3, 1].set_ylabel('c$_{buffer}$ (mg/L)')
# axs[3, 1].grid(linewidth=0.5, linestyle='-.')
# axs[3, 1].set_xlim([0, 900])


# # plt.legend(['Actual', 'Case1', 'Case2', 'Case3'], ncol=3)
# # # fig_1.legend(['Actual', 'Case1', 'Case2', 'Case3'])
# # plt.rcParams["figure.figsize"] =  [8.00, 7.00]
# # plt.setp(axs[-1, :], xlabel='Time(min)')

# plt.legend(['Actual', 'Case2', 'Case3'], ncol=3)
# plt.rcParams["figure.figsize"] =  [8.00, 7.00]
# plt.xlabel('Time(min)', weight='bold', family='monospace', size=13, labelpad=9)
# plt.show()







# # fig_1, axs = plt.subplots(3, figsize=(7,7))
# fig1, axs = plt.subplots(2, 2)
# axs[0, 0].plot(tplot[:-1], actual_trajectories[:,13], 'r',linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case1[:,13], '-.b', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case2[:,13], ':k', linewidth=3)
# axs[0, 0].plot(tplot[:-1], estimate_case3[:,13], '--g', linewidth=3)
# axs[0, 0].set_ylabel('mAb$_{2}$ (mg/L)')
# axs[0, 0].set_xlim([0, 2000])

# axs[0, 1].plot(tplot[:-1], actual_trajectories[:,6], 'r',linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case1[:,6],  '-.b', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case2[:,6],  ':k', linewidth=3)
# axs[0, 1].plot(tplot[:-1], estimate_case3[:,6],  '--g', linewidth=3)
# axs[0, 1].set_ylabel('mAb$_{1}$ (mg/L)')
# axs[0, 1].set_xlim([0, 2000])

# axs[1, 0].plot(tplot[:-1], actual_trajectories[:,3], 'r',linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case1[:,3],  '-.b', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case2[:,3],  ':k', linewidth=3)
# axs[1, 0].plot(tplot[:-1], estimate_case3[:,3],  '--g', linewidth=3)
# axs[1, 0].set_ylabel('GLC$_{1}$ (mM)')
# axs[1, 0].set_xlim([0, 2000])

# axs[1, 1].plot(tplot[:-1], actual_trajectories[:,14], 'r',linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case1[:,14],  '-.b', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case2[:,14],  ':k', linewidth=3)
# axs[1, 1].plot(tplot[:-1], estimate_case3[:,14],  '--g', linewidth=3)
# axs[1, 1].set_ylabel('T ($\degree$C)')
# axs[1, 1].set_xlim([0, 2000])

# fig1.legend(['Actual', 'case1', 'case2', 'case3' ])
# plt.rcParams["figure.figsize"] = [8.00, 7.00]
# plt.setp(axs[-1, :], xlabel='Time(min)')






















